<template>
    <div>
        <Form :model="formItem" inline>
            <FormItem>
                <Input v-model="formItem.company"  style="width: 200px" placeholder="单位"></Input>
            </FormItem>
            <FormItem>
                <Button type="success" @click="search">搜索</Button>
            </FormItem>
            <FormItem>
                <Button type="primary" @click="exportData"><Icon type="ios-download-outline"></Icon>导出</Button>
            </FormItem>
            <FormItem>
                <Button type="info" @click="back()">返回</Button>
            </FormItem>
        </Form>
        <Table border :columns="columns6" :data="data6" ref="table">
        </Table>
    </div>
</template>

<script>
import { getExportSpvOilcardhandlingByjieList } from '@/api/user'
export default {

  name: 'test',

  data () {
    return {
      total: 0,
      formItem: {
        company: ''
      },
      columns6: [
        // {
        //   title: '序号',
        //   key: 'no',
        //   width: 80,
        //   align: 'center'
        // },
        {
          title: '单位名称',
          key: 'company',
          align: 'center'
        },
        {
          title: '问题油卡号',
          key: 'card_num',
          align: 'center'
        },
        {
          title: '问题类型',
          key: 'type',
          align: 'center'
        },
        {
          title: '开卡日期',
          key: 'card_time',
          align: 'center'
        },
        {
          title: '问题类型',
          key: 'problem',
          align: 'center'
        }
        // {
        //   title: '操作',
        //   slot: 'action',
        //   width: 150,
        //   align: 'center'
        // }
        // {
        //   title: '交易时间',
        //   key: 'f'
        // }
      ],
      data6: []
    }
  },

  props: {

  },

  components: {

  },

  computed: {

  },

  methods: {
    async init (data) {
      getExportSpvOilcardhandlingByjieList(data).then(ret => {
        this.data6 = ret.data.data
        this.data6.forEach(item => {
          item.type = '此卡在登记台账不存在'
          item.problem = '漏报瞒报卡'
          let a = new Date(item.card_time)
          let y = a.getFullYear()
          let m = a.getMonth() + 1
          let d = a.getDate()
          if (m < 10) {
            m = '0' + m
          }
          if (d < 10) {
            d = '0' + d
          }
          item.card_time = y + '-' + m + '-' + d
        })
      })
    },
    search () {
      const data = {
        company: this.formItem.company
      }
      this.init(data)
    },
    exportData () {
      for (let i = 0; i < this.data6.length; i++) {
        if (this.data6[i].card_num) {
          this.data6[i].card_num = '\t' + this.data6[i].card_num
        }
      }
      this.$refs.table.exportCsv({
        filename: '导出文件',
        columns: this.columns6,
        data: this.data6
      })
    },
    back () {
      this.$router.push({
        name: 'refueling-eight'
      })
    }
  },

  watch: {

  },

  mounted () {
    this.init()
  }

}
</script>

<style scoped>

</style>
